package com.cman777.springc.idempotence.storage;

import com.cman777.springc.idempotence.ResultWrapper;

import java.io.Serializable;
import java.util.function.Supplier;

/**
 * @author chenzhicong
 * @time 2020/9/15 10:30
 */
public interface Storage {
    /**
     * supplier不一定会执行  保证原子性
     */
    boolean setIfAbsent(String key, Supplier<ResultWrapper> supplier);

    /**
     * 得保证幂等性
     */
    boolean setIfAbsent(String key, ResultWrapper value);

    boolean delete(String idempotenceId);


    <T extends Serializable> ResultWrapper<T> getResult(String idempotenceId);


    boolean exists(String key);


}
